package com.ug_project.adapters

import android.content.Context
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import com.chad.library.adapter.base.BaseSectionQuickAdapter
import com.chad.library.adapter.base.entity.SectionEntity
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.ug_project.objects.isNull
import java.util.*

/**
 * Created by yurqi on 2018/4/19.
 * QQ: 906120575 | Wechat : kalip008
 * Tashkin Company
 */
//class RecyclerSectionAdapter<D, T : SectionEntity<D>>(
//        val context: Context,
//        var item_res_id: Int,
//        var section_res_id: Int,
//        var data: ArrayList<T>) : BaseSectionQuickAdapter<T,
//        BaseViewHolder>(item_res_id, section_res_id, data) {
//    internal var _onConvert: (itemView: View, item: D) -> Unit = { a, b -> }
//    internal var _onConvertHead: (itemView: View, item: T) -> Unit = { a, b -> }
//    private var _inflater: LayoutInflater? = null
//
//
//    override fun convertHead(helper: BaseViewHolder, item: T) {
////        when (helper.itemView) {
////            is ViewGroup -> {
////                helper.itemView.font = FONT_NAME
////            }
////            is TextView -> {
////                helper.itemView.font = FONT_NAME
////            }
////        }
//        _onConvertHead(helper.itemView, item)
//    }
//
//    override fun convert(helper: BaseViewHolder, item: T) {
////        when (helper.itemView) {
////            is ViewGroup -> {
////                helper.itemView.font = FONT_NAME
////            }
////            is TextView -> {
////                helper.itemView.font = FONT_NAME
////            }
////        }
//        _onConvert(helper.itemView, item.t)
//    }
//
//
//    fun onConvert(action: (view: View, data: D) -> Unit) {
//        _onConvert = action
//    }
//
//    fun onConvertHead(action: (view: View, data: T) -> Unit) {
//        _onConvertHead = action
//    }
//
//
//    fun addHeader(layoutRedId: Int, action: (view: View) -> Unit) {
//        _inflater.isNull {
//            _inflater = LayoutInflater.from(context)
//        }
//        val headerView = _inflater!!.inflate(layoutRedId, null, false)
//        action(headerView)
//        addHeaderView(headerView)
//    }
//
//    fun addFooter(layoutRedId: Int, action: (view: View) -> Unit) {
//        _inflater.isNull {
//            _inflater = LayoutInflater.from(context)
//        }
//        val footerView = _inflater!!.inflate(layoutRedId, null, false)
//        action(footerView)
//        addFooterView(footerView)
//    }
//
//}

//fun <D> Context.createRecyclerSectionAdapter(
//        item_res_id: Int,
//        section_res_id: Int,
//        datas: ArrayList<SectionEntity<D>>,
//        action: RecyclerSectionAdapter<D, SectionEntity<D>>.() -> Unit
//): RecyclerSectionAdapter<D, SectionEntity<D>> {
//    val temp = RecyclerSectionAdapter(this, item_res_id, section_res_id, datas)
//    temp.action()
//    return temp
//}

//fun <D, T : SectionEntity<D>> Context.createRecyclerSectionAdapter(
//        item_res_id: Int,
//        section_res_id: Int,
//        datas: ArrayList<T>,
//        action: RecyclerSectionAdapter<D, T>.() -> Unit
//): RecyclerSectionAdapter<D, T> {
//    val temp = RecyclerSectionAdapter(this, item_res_id, section_res_id, datas)
//    temp.action()
//    return temp
//}
//
//
//fun <D, T : SectionEntity<D>> Fragment.createRecyclerSectionAdapter(
//        item_res_id: Int,
//        section_res_id: Int,
//        datas: ArrayList<T>,
//        action: RecyclerSectionAdapter<D, T>.() -> Unit
//): RecyclerSectionAdapter<D, T> {
//    return activity.createRecyclerSectionAdapter(item_res_id, section_res_id, datas, action)
//}